package appapi.controller.oider;

import appapi.Vo.AddModuletypeVo;
import appapi.config.CurrentUser;
import appapi.entity.basic.UserInfo;
import appapi.utils.JwtUtil;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.io.Console;



@Api(tags = "系统设置")
@RestController
@RequestMapping("/api/test")
public class TestController {
    @GetMapping("/level1")
    public Long level1(HttpServletRequest request) {
        String token = request.getHeader("token");
        Long userId = JwtUtil.getUserIdByJwtToken(token);
        //log.info("userId={}", userId);
        return userId;
    }

    @GetMapping("/level2")
    public Long level2(HttpServletRequest request) {
        Long userId = Long.parseLong(request.getHeader("userId"));
        //log.info("userId={}", userId);
        return userId;
    }

    @GetMapping("/level3")
    public UserInfo level3(Long userId, String userName) {
        //log.info("userId={}", userId);
        UserInfo user= new UserInfo();
        user.setUserid(userId);
        user.setUsername(userName);
        return  user;
    }

//    @PostMapping("/level3Post")
//    public Long level3Post(@RequestBody AddModuletypeVo info) {
//        //log.info("userId={}", user.getUserId());
//        return info.get();
//    }

    @GetMapping("/level4")
    public UserInfo level4(@CurrentUser UserInfo user) {
        //log.info("userId={},username={}", user.getUserId(), user.getName());
        return user;
    }


}
